import java.util.Comparator;
public class Pair{
	int a, b;
	RectNode r;
	public Pair(int a, int b, RectNode r){
		this.a = a;
		this.b = b;
		this.r = r;
	}
	
	public int distanceTo(Pair p){
		return (int)Math.abs(a - p.a) + (int)Math.abs(b - p.b);
	}

	public int getSide(Pair p2){
		if(a < p2.a && b < p2.b) return Edge.LEFT;
		else if(a < p2.a && b > p2.b) return Edge.TOP;
		else if(a > p2.a && b > p2.b) return Edge.RIGHT;
		else return Edge.BTM;
	}
	
	public int[] getXY(Pair p2){
		int da = a - p2.a;
		int db = b - p2.b;
		return new int[]{
			(int)Math.round(Math.cos(45) * da + Math.sin(45) * db),
			(int)Math.round(Math.sin(45) * da + Math.cos(45) * db)
		};
	}

	public static class DistComp implements Comparator{
		Pair p;
		public DistComp(Pair p){
			this.p = p;
		}
	
		public int compare(Object arg0, Object arg1) {
			if(arg0 instanceof Pair && arg1 instanceof Pair){
				int dist = p.distanceTo((Pair)arg0) - p.distanceTo((Pair)arg1);
				return dist;
			}
			return 0;
		}

	}
}
